/**
 * Copyright (c) 2011-9-23 WKM and/or its affiliates. 
 * Use is subject to license terms.
 * All rights reserved.
 */
package org.wkm.util;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * The class note
 * @version 1.0 2012-1-12
 * @author WUKUNMENG
 */
public class CalendarUtil {

	/**
	 * 静态方法
	 */
	private CalendarUtil(){}
	
	
	public static String DATE_LINE_SEPARATOR = "yyyy-MM-dd";
	
	public static String DATE_CHINESE_SEPARATOR = "yyyy年MM月dd日";
	
	public static String DATE_TIME_LINE_SEPARATOR = "yyyy-MM-dd HH:mm:ss";
	
	public static String DATE_TIME_CHINESE_SEPARATOR = "yyyy年MM月dd日HH时mm分ss秒";
	
	/**
	 * 获取指定格式的日期
	 * @param source
	 * @param format
	 * @return
	 */
	public static String getDate(Date source,String format) {
		SimpleDateFormat formatDate = new SimpleDateFormat(format);
		return formatDate.format(source);
	}
	
	/**
	 * 按照指定格式获取今天的日期
	 * @param format
	 * @return 
	 */
	public static String getDateToday(String format) {
		return getDate(Calendar.getInstance().getTime(),format);
	}
	
	/**
	 * 按照指定格式获取今天的日期
	 * @param format
	 * @return 
	 */
	public static String getDateToday() {
		return getDateToday(DATE_CHINESE_SEPARATOR);
	}
	
	
	/**
	 * 获取指定格式的日期时间
	 * @param source
	 * @param format
	 * @return
	 */
	public static String getDateTime(Date source,String format) {
		SimpleDateFormat formatDate = new SimpleDateFormat(format);
		return formatDate.format(source);
	}
	
	/**
	 * 按照指定格式获取今天的日期时间
	 * @param format
	 * @return 
	 */
	public static String getDateTimeToday(String format) {
		return getDate(Calendar.getInstance().getTime(),format);
	}
	
	/**
	 * 按照指定格式获取今天的日期时间
	 * @param format
	 * @return 
	 */
	public static String getDateTimeToday() {
		return getDateToday(DATE_TIME_CHINESE_SEPARATOR);
	}
	
	/**
	 * 按照指定格式获取时间毫秒数
	 * @return long
	 */
	public static long getDateTime() {
		return System.currentTimeMillis();
	}
}
